<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "contract_status".
 *
 * @property int $id
 * @property string $title
 * @property int $sort
 * @property string|null $css_style
 *
 * @property Contract[] $contracts
 */
class ContractStatus extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'contract_status';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['title', 'sort'], 'required'],
            [['sort'], 'integer'],
            [['title', 'css_style'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => 'Название',
            'sort' => 'Сортировка',
            'css_style' => 'CSS стиль',
        ];
    }

    /**
     * Gets query for [[Contracts]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getContracts()
    {
        return $this->hasMany(Contract::className(), ['id_status' => 'id']);
    }
}
